package com.jinlejia.erp.ui.customer;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jinlejia.erp.R;

/**
 * @author SongJiaTai
 * @description:客源隐藏业务
 * @date :2019/10/9 11:46
 */
public class CustomerHideDialog extends AlertDialog{
    private boolean isAttention;
    private boolean isGL;

    public CustomerHideDialog(Context context) {
        super(context);
    }

    public void setAttention(boolean attention) {
        isAttention = attention;
    }

    public void setGL(boolean GL) {
        isGL = GL;
    }

    private LinearLayout writeFollow;
    private LinearLayout Interest;
    private LinearLayout oldHouse;
    private LinearLayout newHouse;
    private LinearLayout clearBinding;
    private  LinearLayout updateData;
    private LinearLayout floower;
    private ImageView imgFloower;
    private TextView tvFloower;
    private LinearLayout clearBindingLayout;
    private LinearLayout layoutZw;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = this.getWindow();
        // *** 主要就是在这里实现这种效果的.
        // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容
        window.setContentView(R.layout.dialog_customerhide);
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawable(new ColorDrawable());
        window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

        //写跟进
        writeFollow = window.findViewById(R.id.writeFollow);
        //兴趣
        Interest = window.findViewById(R.id.Interest);
        //二手房带开
        oldHouse = window.findViewById(R.id.oldHouse);
        //新房报备
        newHouse = window.findViewById(R.id.newHouse);
        //解除关联
        clearBinding  = window.findViewById(R.id.clearBinding);
        //修改资料
        updateData = window.findViewById(R.id.updateData);
        //收藏
        floower = window.findViewById(R.id.floower);
        //取消
        TextView tvCancle = window.findViewById(R.id.tvCancle);
        tvCancle.setOnClickListener(view -> dismiss());

        imgFloower =  window.findViewById(R.id.imgFloower);
        tvFloower = window.findViewById(R.id.tvFloower);
        clearBindingLayout = window.findViewById(R.id.clearBinding);
        layoutZw = window.findViewById(R.id.layoutZw);
        if (isAttention){
            imgFloower.setImageResource(R.mipmap.ic_ky_yfollow);
            tvFloower.setText("已收藏");
        }else{
            imgFloower.setImageResource(R.mipmap.ic_ky_follow);
            tvFloower.setText("收藏");
        }

        if (isGL){
            clearBindingLayout.setVisibility(View.VISIBLE);
            layoutZw.setVisibility(View.GONE);
        }else{
            clearBindingLayout.setVisibility(View.GONE);
            layoutZw.setVisibility(View.VISIBLE);
        }

    }

    public LinearLayout getwriteFollow(){
        return writeFollow;
    }

    public LinearLayout getInterest(){
        return Interest;
    }

    public LinearLayout getoldHouse(){
        return oldHouse;
    }

    public LinearLayout getnewHouse(){
        return newHouse;
    }

    public LinearLayout getclearBinding(){
        return clearBinding;
    }

    public LinearLayout getupdateData(){
        return updateData;
    }

    public LinearLayout getfloower(){
        return floower;
    }
}
